<template>
	<view class="myBox">
		<view class="topTitle flex-sp-center">
			<view class="Title">
				医联•互联网医院
				<view class="">开启美好的一天</view>
			</view>
			<view class="flex-center-center" @click="scanCode()">
				<view class="ScanCode flex-center-center">
					<image src="@/static/my/scan.png" mode=""></image>
					扫一扫
				</view>
				<view class="tz" @click.stop="goinfo('pages/my/news/news')">
					<image src="@/static/CommonTools/tz.png" mode=""></image>
				</view>
			</view>
		</view>
		<view class="doctor">
			<view class="" @click="goinfo('pages/my/MyProfile/MyProfile')">
				<view class="title flex-center">
					<image :src="data.avatar" mode=""></image>
					<view class="nameBox">
						<view class="name">
							{{ data.doctorName }}
							<text>{{ data.titleName }}</text>
							<text>{{ data.departName }}</text>
						</view>
						<view class="typeBox">
							<text v-if="data.levelName">{{ data.levelName }}</text>
							{{ data.hospitalName }}
						</view>
						<view class="setUp">点击设置资料</view>
					</view>
					<view class="code" @click.stop="Uppop()">
						<image src="@/static/my/code.png" mode=""></image>
					</view>
				</view>
			</view>
		</view>
		<view class="nav flex-sp-center">
			<view class="">
				<view class="">
					{{ data.myPatientCount }}
				</view>
				我的患者
			</view>
			<view class="">
				<view class="">
					{{ data.patientConsultCount }}
				</view>
				患者咨询
			</view>
			<view class="" @click="handleGoToConversationList()">
				<view class="">
					{{ data.patientAppointCount }}
				</view>
				患者预约
			</view>
			<view class="">
				<view class="">
					{{ data.consultationFrequency }}
				</view>
				会诊次数
			</view>
		</view>
		<view class="module flex-sp-center">
			<view class="left">
				<image @click="goConsultationRoom(1)" class="" src="@/static/index/zs.png" mode="aspectFit"></image>
			</view>
			<view class="right">
				<image @click="goConsultationRoom(2)" src="@/static/index/ggzs.png" mode="aspectFit"></image>
				<view class="flex-sp-center">
					<image @click="goAppointment(1)" src="@/static/index/yy.png" mode="aspectFit"></image>
					<image src="@/static/index/hz.png" mode="aspectFit"
						@click="goinfo('pages/ConsultationRoom/consultationList/consultationList')"></image>
				</view>
			</view>
		</view>
		<view class="currency_card mt_30 list">
			<view class="flex-sp-center" @click="goConsultationRoom(3)">
				<image src="@/static/index/list1.png" mode=""></image>
				<view class="">
					<view class="title flex-sp-center">今日问诊</view>
					<view class="flex-sp-center listText">问诊中 {{ data.todayConsultCount }}</view>
				</view>
				<uni-icons type="right" size="16"></uni-icons>
			</view>
			<view class="flex-sp-center" @click="goConsultationList(2)">
				<image src="@/static/index/list3.png" mode=""></image>
				<view class="">
					<view class="title flex-sp-center">今日会诊</view>
					<view class="flex-sp-center listText">会诊中 {{ data.todayConsultationNum }}</view>
				</view>
				<uni-icons type="right" size="16"></uni-icons>
			</view>
			<view class="flex-sp-center" @click="goAppointment(2)">
				<image src="@/static/index/list2.png" mode=""></image>
				<view class="">
					<view class="title flex-sp-center">今日预约</view>
					<view class="flex-sp-center listText">已预约 {{ data.todayAppointNum }}</view>
				</view>
				<uni-icons type="right" size="16"></uni-icons>
			</view>
		</view>
		<uni-popup ref="popup" type="center">
			<view class="">
				<QRCode :code="data.userId"></QRCode>
			</view>
		</uni-popup>
		<UnauditedPup :data="data.auditStatus" :auditReason="data.auditReason"></UnauditedPup>
		<image class="zxxf" @click="goinfo('pages/ContinuedPrescription/index')" src="@/static/index/zxxf.png" mode="">
		</image>
	</view>
</template>

<script>
	import {
		getDoctorStatic
	} from '@/api/user'
	import {
		CreateGroup
	} from '@/utils/TIM'
	export default {
		data() {
			return {
				data: {},
				role: uni.getStorageSync('role'),
			}
		},
		onShow() {
			this.getDoctorStatic()
		},
		onLoad() {
			if (this.role == 2) {
				uni.navigateTo({
					url: `/pages/Pharmacist/my`,
				})
			}
		},
		methods: {
			scanCode() {
				uni.scanCode({
					success: function(res) {
						console.log('条码类型：' + res.scanType)
						console.log('条码内容：' + res.result)
					},
				})
			},
			Uppop() {
				this.$refs.popup.open('center')
			},
			// 进入会话列表
			handleGoToConversationList() {
				uni.navigateTo({
					url: `/TUIKit/components/TUIConversation/index`,
				})
			},
			getDoctorStatic() {
				getDoctorStatic().then(res => {
					this.data = res.data
					// 缓存用户信息
					uni.setStorageSync('userInfo', res.data)
				})
			},
			goConsultationList(e) {
				uni.navigateTo({
					url: `/pages/ConsultationRoom/consultationList/consultationList?type=${e}`,
				})
			},
			goConsultationRoom(e) {
				uni.navigateTo({
					url: `/pages/ConsultationRoom/index?type=${e}`,
				})
			},
			goAppointment(e) {
				uni.navigateTo({
					url: `/pages/ConsultationRoom/TodayAppointment/TodayAppointment?type=${e}`,
				})
			},
			goinfo(e, id) {
				if (id) {
					uni.navigateTo({
						url: `/${e}?id=${id}`,
					})
				} else {
					uni.navigateTo({
						url: `/${e}`,
					})
				}
			},
		},
	}
</script>

<style lang="less" scopde>
	.zxxf {
		width: 102rpx;
		height: 102rpx;
		position: fixed;
		right: 20rpx;
		bottom: 120rpx;
	}

	.Unaudited {
		width: 100%;
		height: 100vh;
		position: fixed;
		top: 0%;
		left: 0%;
		background-color: #00000080;

		.box {
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
			border-radius: 20rpx;
			width: 400rpx;
			height: 400rpx;
			background-color: #fff;
			text-align: center;
			padding: 20rpx;
			box-sizing: border-box;

			image {
				width: 205rpx;
				height: 168rpx;
			}

			.title {
				text-align: center;
				font-weight: bold;
				font-size: 36rpx;
				color: #333;
				margin-top: 20rpx;
			}

			.text {
				margin-top: 10rpx;
				width: 100%;
				color: #999;
				font-size: 26rpx;
				text-align: left;
			}
		}
	}

	.myBox {
		min-height: 100vh;
		background-image: url(@/static/my/myBg.png);
		background-size: 100% 726rpx;
		background-repeat: no-repeat;
		padding: 51rpx 30rpx;
		box-sizing: border-box;

		.list {
			padding-top: 36rpx;

			&>view {
				margin-bottom: 62rpx;

				&:last-child {
					margin-bottom: 23rpx;
				}

				&>view {
					flex: 1;

					.title {
						font-weight: bold;
						font-size: 30rpx;
						color: #333333;
					}

					.num {
						display: inline-block;
						min-width: 29rpx;
						height: 28rpx;
						background: #ff4d3d;
						border-radius: 14rpx;
						font-weight: 500;
						font-size: 22rpx;
						color: #ffffff;
						text-align: center;
						line-height: 28rpx;
					}

					.listText {
						margin-top: 20rpx;
						font-weight: 500;
						font-size: 28rpx;
						color: #999999;
					}
				}
			}

			image {
				width: 95rpx;
				height: 95rpx;
				margin-right: 18rpx;
			}
		}

		.module {
			.left {
				image {
					width: 333rpx;
					height: 320rpx;
				}
			}

			.right {
				width: 338rpx;

				image {
					width: 338rpx;
					height: 147rpx;
				}

				&>view {
					image {
						width: 161rpx;
						height: 155rpx;
					}
				}
			}
		}

		.nav {
			height: 123rpx;
			padding: 0 30rpx;

			&>view {
				font-weight: 500;
				font-size: 26rpx;
				color: #666666;

				&>view {
					font-weight: 500;
					font-size: 34rpx;
					color: #333333;
					text-align: center;

					image {
						width: 42rpx;
						height: 45rpx;
						margin-right: 18rpx;
					}
				}
			}
		}

		.doctor {
			width: 690rpx;
			min-height: 182rpx;
			border-radius: 30rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-around;

			&>view {
				width: 100%;
			}

			.title {
				.code {
					image {
						width: 63rpx;
						height: 60rpx;
					}
				}

				.nameBox {
					flex: 1;
				}

				.name {
					font-weight: bold;
					font-size: 32rpx;
					color: #333333;

					text {
						font-weight: 500;
						font-size: 24rpx;
						color: #666666;
						margin-left: 19rpx;
					}
				}

				image {
					width: 118rpx;
					height: 118rpx;
					border-radius: 50%;
					margin-right: 21rpx;
				}
			}

			.typeBox {
				margin-top: 5rpx;

				text {
					display: inline-block;
					width: 63rpx;
					height: 33rpx;
					background: #def7ed;
					border-radius: 10rpx;
					font-weight: 500;
					font-size: 22rpx;
					color: #23cc88;
					text-align: center;
					line-height: 33rpx;
					margin-right: 10rpx;
				}
			}

			.setUp {
				margin-top: 5rpx;
				font-weight: 500;
				font-size: 24rpx;
				color: #999999;
			}
		}

		.topTitle {
			.Title {
				font-weight: 800;
				font-size: 34rpx;
				color: #333333;

				view {
					font-weight: 500;
					font-size: 24rpx;
					color: #999999;
				}
			}

			.tz {
				image {
					width: 60rpx;
					height: 68rpx;
				}
			}

			.ScanCode {
				width: 145rpx;
				height: 60rpx;
				border-radius: 35rpx;
				border: 2px solid #3e6efe;
				font-weight: 500;
				font-size: 24rpx;
				color: #3e6efe;
				margin-right: 32rpx;

				image {
					width: 24rpx;
					height: 24rpx;
					margin-right: 9rpx;
				}
			}
		}
	}
</style>